
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/abc.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:24:03 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>abc &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../live.sympy.org/static/live-sphinx.js"></script>
    
    <link rel="shortcut icon" href="../_static/sympy-notailtext-favicon.ico"/>
    <link href="abc.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Algebras" href="algebras.html" />
    <link rel="prev" title="SymPy Modules Reference" href="index.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="algebras.html" title="Algebras"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="index.html" title="SymPy Modules Reference"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">abc</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-sympy.abc">
<span id="abc"></span><h1>abc<a class="headerlink" href="#module-sympy.abc" title="Permalink to this headline">¶</a></h1>
<p>This module exports all latin and greek letters as Symbols, so you can
conveniently do</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
</pre></div>
</div>
<p>instead of the slightly more clunky-looking</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x y&#39;</span><span class="p">)</span>
</pre></div>
</div>
<section id="caveats">
<h2>Caveats<a class="headerlink" href="#caveats" title="Permalink to this headline">¶</a></h2>
<p>1. As of the time of writing this, the names <code class="docutils literal notranslate"><span class="pre">O</span></code>, <code class="docutils literal notranslate"><span class="pre">S</span></code>, <code class="docutils literal notranslate"><span class="pre">I</span></code>, <code class="docutils literal notranslate"><span class="pre">N</span></code>,
<code class="docutils literal notranslate"><span class="pre">E</span></code>, and <code class="docutils literal notranslate"><span class="pre">Q</span></code> are colliding with names defined in SymPy. If you import them
from both <code class="docutils literal notranslate"><span class="pre">sympy.abc</span></code> and <code class="docutils literal notranslate"><span class="pre">sympy</span></code>, the second import will “win”.
This is an issue only for * imports, which should only be used for short-lived
code such as interactive sessions and throwaway scripts that do not survive
until the next SymPy upgrade, where <code class="docutils literal notranslate"><span class="pre">sympy</span></code> may contain a different set of
names.</p>
<p>2. This module does not define symbol names on demand, i.e.
<code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">sympy.abc</span> <span class="pre">import</span> <span class="pre">foo</span></code> will be reported as an error because
<code class="docutils literal notranslate"><span class="pre">sympy.abc</span></code> does not contain the name <code class="docutils literal notranslate"><span class="pre">foo</span></code>. To get a symbol named <code class="docutils literal notranslate"><span class="pre">foo</span></code>,
you still need to use <code class="docutils literal notranslate"><span class="pre">Symbol('foo')</span></code> or <code class="docutils literal notranslate"><span class="pre">symbols('foo')</span></code>.
You can freely mix usage of <code class="docutils literal notranslate"><span class="pre">sympy.abc</span></code> and <code class="docutils literal notranslate"><span class="pre">Symbol</span></code>/<code class="docutils literal notranslate"><span class="pre">symbols</span></code>, though
sticking with one and only one way to get the symbols does tend to make the code
more readable.</p>
<p>The module also defines some special names to help detect which names clash
with the default SymPy namespace.</p>
<p><code class="docutils literal notranslate"><span class="pre">_clash1</span></code> defines all the single letter variables that clash with
SymPy objects; <code class="docutils literal notranslate"><span class="pre">_clash2</span></code> defines the multi-letter clashing symbols;
and <code class="docutils literal notranslate"><span class="pre">_clash</span></code> is the union of both. These can be passed for <code class="docutils literal notranslate"><span class="pre">locals</span></code>
during sympification if one desires Symbols rather than the non-Symbol
objects for those names.</p>
</section>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">S</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">_clash1</span><span class="p">,</span> <span class="n">_clash2</span><span class="p">,</span> <span class="n">_clash</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span><span class="p">(</span><span class="s2">&quot;Q &amp; C&quot;</span><span class="p">,</span> <span class="nb">locals</span><span class="o">=</span><span class="n">_clash1</span><span class="p">)</span>
<span class="go">C &amp; Q</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span><span class="p">(</span><span class="s1">&#39;pi(x)&#39;</span><span class="p">,</span> <span class="nb">locals</span><span class="o">=</span><span class="n">_clash2</span><span class="p">)</span>
<span class="go">pi(x)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">S</span><span class="p">(</span><span class="s1">&#39;pi(C, Q)&#39;</span><span class="p">,</span> <span class="nb">locals</span><span class="o">=</span><span class="n">_clash</span><span class="p">)</span>
<span class="go">pi(C, Q)</span>
</pre></div>
</div>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">abc</a><ul>
<li><a class="reference internal" href="#caveats">Caveats</a></li>
<li><a class="reference internal" href="#examples">Examples</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="index.html"
                        title="previous chapter">SymPy Modules Reference</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="algebras.html"
                        title="next chapter">Algebras</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/modules/abc.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="algebras.html" title="Algebras"
             >next</a> |</li>
        <li class="right" >
          <a href="index.html" title="SymPy Modules Reference"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="index.html" >SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">abc</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/abc.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:24:03 GMT -->
</html>